package dk.dashboardFP.shapes {
	import flash.display.Sprite;

	/**
	 * @author jk
	 */
	public class Box extends Sprite {
		private var _nLineAlpha : Number;
		private var _nWidth : Number;
		private var _nHeight : Number;
		private var _uintColor : uint;
		private var _nAlpha : Number;
		private var _nRounded : Number;
		private var _oLineColor : Object;

		public function Box(nWidth : Number, nHeight : Number, uintColor : uint=0xff0000, nAlpha : Number=1, nRounded : Number=0, oLineColor:Object=null, nLineAlpha:Number=1) {
		
			_oLineColor = oLineColor;
			_nRounded = nRounded;
			_nAlpha = nAlpha;
			_uintColor = uintColor;
			_nHeight = nHeight;
			_nWidth = nWidth;
			_nLineAlpha = nLineAlpha;
			
			drawBox();
		}
		
		private function drawBox() : void {
			
			graphics.clear();
			graphics.beginFill(_uintColor, _nAlpha);
			
			if (_oLineColor!=null) {
				graphics.lineStyle(1, uint(_oLineColor), _nLineAlpha);
			}
			
			if (_nRounded!=0) {
				graphics.drawRoundRect(0, 0, _nWidth, _nHeight, _nRounded, _nRounded);
			} else {
				graphics.drawRect(0, 0, _nWidth, _nHeight);
			}
			
		}

		override public function set width(value : Number) : void {
			if (_nRounded!=0) {
				_nWidth = value;
				drawBox();
			} else {
				super.width = value;
			}
		}

		override public function set height(value : Number) : void {
			
			if (_nRounded!=0) {
				_nHeight = value;
				drawBox();
			} else {
				super.height = value;
			}
		}
	}
}
